1

Mac OS X 10.10 下安装Nginx, 终端纪录如下:

Installing nginx
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.8.0.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring nginx-1.8.0.yosemite.bottle.tar.gz
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx at login:
    ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don't want/need launchctl, you can just run:
    nginx
==> Summary

运行nginx,报错:

nginx
dyld: Library not loaded: /usr/local/lib/libpcre.1.dylib
  Referenced from: /usr/local/bin/nginx
  Reason: image not found
[1]    954 trace trap  nginx

通过brew doctor看看到底是哪里出了问题:

brew doctor

获得如下信息:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:

    pcre

按照提示操作,结果又抛出一条错误:

 brew link pcre
Linking /usr/local/Cellar/pcre/8.36... 
Error: Could not symlink share/man/man3/pcre.3
/usr/local/share/man/man3 is not writable.

Google一下,发现一个解决方案

sudo chown -R mcbird /usr/local/share/man/man3

接着,再link操作即可:

brew link pcre  

完成后,就可以成功运行nginx了。


MockingBird
5.8k 声望743 粉丝